<script setup>
import { ref } from 'vue'

const subListState = ref(false)

</script>

<template>
  <div class="lite-topbar main-top">
    <div class="nav-top">
      <div v-if="false" class="nav-left lite-iconf">
        <van-icon name="contact-o" />
      </div>
      <div class="nav-left unlogin-logo"></div>
      <a class="nav-search unlogin-search">
        <aside>
          <label class="m-search">
            <div class="m-font m-font-search">
              <van-icon name="search" />
            </div>
            <div class="m-text-cut">大家都在搜：#王楚然回应臭脸#</div>
          </label>
        </aside>
      </a>
      <div class="nav-right">
        <div class="lite-iconf lite-iconf-releas">
          <van-icon name="edit" />
        </div>
      </div>
    </div>
    <div class="nav-main">
      <div class="m-box">
        <div class="m-box-col inner-box">
          <div class="scroll-box slide-container">
            <div class="slide-wrap">
              <ul class="nav_item">
                <li class="item_li" :class="{ cur: item == 1 }" v-for="item in 10" :key="item">
                  <span>
                    热门
                    <em></em>
                  </span>
                </li>
              </ul>
            </div>
            <div class="lite-nav-sublist m-col-4" v-if="subListState">
              <ul class="m-auto-list">
                <li class="m-auto-box" :class="{ cur: item == 1 }" v-for="item in 11" :key="item">
                  <span class="m-text-cut">热门</span>
                </li>
              </ul>
            </div>
          </div>
        </div>
        <div @click="subListState = !subListState" class="nav-plus m-box-center m-box-center-a">
          <van-icon name="arrow-down" :class="{ 'aniRotate': subListState }" class="m-font-arrow-down" />
        </div>
      </div>
    </div>
  </div>
</template>

<style scoped lang="scss">
.lite-topbar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  padding: 0;
  background-color: #fafafa;
  color: #262626;
  border-top-width: 0;
  border-right-width: 0;
  border-bottom-width: 1px;
  border-left-width: 0;
  border-color: #e6e6e6;
  border-style: solid;
  font-size: 16px;
  z-index: 995;

}

.lite-topbar {

  .nav-left,
  .nav-search,
  .nav-main,
  .nav-right {
    position: absolute;
    line-height: 44px;
  }

  .main-top {
    height: 84px;
  }

  .nav-left {
    left: 12px;
  }

  .nav-search {
    left: 44px;
    right: 86px;
    line-height: 40px;

    &.unlogin-search {
      right: 44px;
    }
  }

  .nav-right {
    right: 15px;

    .lite-iconf-releas {
      right: 0;
    }

    .lite-iconf {
      position: absolute;
      color: #282f3c;
    }
  }

  &.main-top {
    height: 84px;

    .nav-main {
      top: 40px;
      right: 0;
      left: 0;
      font-size: 1rem;
      color: #a5adb5;

      .inner-box {
        overflow: hidden;
        width: 1px;

        &:after,
        &:before {
          content: "";
          position: absolute;
          top: 0;
          bottom: 3px;
          z-index: 9;
          width: 12px;
        }

        &:before {
          left: 0;
          background: linear-gradient(90deg, #fafafa 0, #fafafa 50%, hsla(0, 0%, 98%, 0));
        }
      }

      .scroll-box {
        scroll-behavior: smooth;
      }
    }
  }

  .nav-main {
    .nav_item {
      white-space: nowrap;

      .item_li {
        display: inline-block;
        margin: 0 12px;

        &.cur {
          color: #000;

          span {
            em {
              display: block;
              position: absolute;
              bottom: -8px;
              left: 50%;
              width: 14px;
              margin-left: -5.4px;
              border-top: 2.5px solid #282f3c;
            }
          }
        }

        span {
          font-size: 16px;
          position: relative;
          vertical-align: middle;
          cursor: pointer;
        }
      }
    }

    .nav-plus {
      width: 42px;
      position: relative;
    }
  }
}

.lite-iconf {
  font-size: 28px;
}

.unlogin-logo {
  width: 26px;
  height: 40px;
  background-image: url('../assets/img/pwalogo.svg');
  background-position: 0 12px;
}

.icon-logo-qq,
.unlogin-logo {
  background-repeat: no-repeat;
  background-size: 100%;
}

.m-search {
  display: block;
  background: #e3e4e6;
  color: #939393;
  border-radius: .25rem;
  box-sizing: border-box;
  position: relative;
}

.m-search {
  margin: 8px 9px;
  color: #bdbdbd;
  border-radius: 16px;

  .m-font {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    left: .8125rem;
  }

  .m-font {
    left: 8px;
  }

  .m-text-cut {
    padding-left: 30px !important;
    background-color: #ebebec !important;
    font-size: 14px !important;
  }

  .m-text-cut {
    border: none;
    background: #fff;
    height: 28px;
    line-height: 28px;
    font-size: 14px;
    padding: 0 0 0 30px;
    border-radius: 16px;
  }
}

.m-box {
  display: flex;
}

.m-box-col {
  flex: 1;
  width: 100%;
  display: block;
  min-width: 0;
}

.slide-container {
  height: 44px;

  .slide-wrap {
    position: relative;
    padding-bottom: 12px;
    overflow-x: scroll;
    overflow-y: hidden;
    white-space: nowrap;
  }
}

.m-box-center-a {
  display: flex;
  align-items: center;
}

.m-box-center {
  display: flex;
  justify-content: center;
}

.m-font-arrow-down {
  font-size: 20px;
  transition: transform .4s ease;
}

.lite-nav-sublist {
  position: absolute;
  top: 44px;
  left: 0;
  right: 0;
  text-align: left;
  padding: 0 8px 20px;
  color: #333;
  background-color: #fafafa;

  .m-auto-list {
    width: 100%;
  }

  .m-auto-box {
    position: relative;
    padding: 0 8px;
    font-size: 14px;
    text-align: center;
    margin-top: 8px;

    &.cur {
      color: #ff8200;
    }

    span {
      display: inline-block;
      width: 100%;
      height: 34px;
      line-height: 34px;
      padding: 0 4px;
      vertical-align: middle;
      background-color: #eee;
      border-radius: 3px;
    }
  }
}

.m-auto-box {
  display: inline-block;
  vertical-align: top;
  box-sizing: border-box;
}

.aniRotate {
  transform: rotate(180deg);
}
</style>